package com.IODemo.objectSerializable;


import java.io.*;

/**
 * @Author milian
 * @Date 2021/7/28 0028 10:11
 */
public class objectSerializableDemo {
    public static void main(String[] args) throws IOException {
        ObjectOutputStream oos= new ObjectOutputStream(new FileOutputStream("H:\\test\\test.txt"));
        Student s1 = new Student("张三", 12);
        Student s2 = new Student("张", 13);
        Student s3 = new Student("张三e", 14);
        oos.writeObject(s1);
        oos.writeObject(s2);
        oos.writeObject(s3);
        oos.close();
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("H:\\test\\test.txt"));
        while (true){
            try {
                Object o = ois.readObject();
                System.out.println(o);
            } catch (EOFException | ClassNotFoundException e) {
               break;
            }

        }
        ois.close();
    }
}
